package com.googlecode.imanager.jasper;

import com.googlecode.imanager.client.Document;
import com.googlecode.imanager.client.bridge.IDocument;
import com.googlecode.imanager.client.style.PageSettings;
import com.googlecode.imanager.core.base.BridgeApplication;
import com.googlecode.imanager.core.base.style.ComputedTheme;
import com.googlecode.imanager.jasper.layout.RScrollBox;

/**
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public class RDocument extends RScrollBox implements IDocument {

    private int pageIndex;
    private int pageCount;
    private ComputedTheme computedTheme;
    
    public RDocument(BridgeApplication bridge, Document source) {
        super(bridge, source);
    }

    @Override
    protected void start() {
        computedTheme = new ComputedTheme(getSource());
        super.start();
    }

    @Override
    public ComputedTheme getComputedTheme() {
        return computedTheme;
    }

    @Override
    public Document getSource() {
        return (Document) source;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }

    public int getPageCount() {
        return pageCount;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public void lockDocument(boolean isLock) {
        if (isLock){
            target.setX(0);
            target.setY(0);
            target.setVisible(true);
        } else {
            target.setX(source.getLeft());
            target.setY(source.getTop());
            target.setVisible(source.isVisible());
        }
        setTreePrinting(isLock);
    }
    
    @Override
    public void setModal(boolean modal) {
        // nothing to do
    }

    @Override
    public void setTitle(String title) {
        // nothing to do
    }

    @Override
    public void scrollToPage(int pageNo) {
        // nothing to do
    }

    @Override
    public void setPageSettings(PageSettings pageSettings) {
        // TODO Auto-generated method stub
    }

}
